Skip to content

fix ICE when no mangle generic#4929

Closed
HerrCai0907 wants to merge 1 commit into
rust-lang:masterfrom
HerrCai0907:fix/no-mangle-generic
Closed

fix ICE when no mangle generic#4929
HerrCai0907 wants to merge 1 commit into
rust-lang:masterfrom
HerrCai0907:fix/no-mangle-generic

Conversation

@HerrCai0907

Copy link
Copy Markdown
Contributor

fixed: rust-lang/rust#154385

Extern symbols can be generic functions because it is a compilation warning instead of error.
But when instancing Instance::mono, it requires non generic functions.

e.g.

#[unsafe(no_mangle)]
fn foo<T: std::fmt::Debug>(value: T)

The fix is adding an additional check before create instance.

@rustbot

rustbot commented Mar 29, 2026

Copy link
Copy Markdown
Collaborator

Thank you for contributing to Miri! A reviewer will take a look at your PR, typically within a week or two.
Please remember to not force-push to the PR branch except when you need to rebase due to a conflict or when the reviewer asks you for it.

@rustbot rustbot added the S-waiting-on-review Status: Waiting for a review to complete label Mar 29, 2026
@RalfJung

Copy link
Copy Markdown
Member

Thanks for the PR!

However, before we do anything like this and risk papering over a deeper problem, we need to figure out why this code isn't rejected by rustc. Generic no_mangle items make no sense. Why is that not a hard error?

@saethlin

Copy link
Copy Markdown
Member

The lint dates back to rust-lang/rust#30269 and I've been unable to find any conversation about the decision to make it a warning. IMO the most sensible thing here is a hard error, the compiler ignoring #[no_mangle] seems really bad.

@oli-obk

oli-obk commented Mar 29, 2026

Copy link
Copy Markdown
Contributor

Yea, we should just crater turning the lint into an error

@HerrCai0907

Copy link
Copy Markdown
Contributor Author

for this kind of language change(warn -> error), should i create a rfc firstly? sorry i am a new comer of rust community.

@oli-obk

oli-obk commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

You can open a PR for rustc directly. You can assign it to me with r? @oli-obk in the main PR message or a comment.

I'll crater it (run it on all crates on crates.io), and then will send it to the lang team for FCPing it. This change doesn't need an RFC

@RalfJung

Copy link
Copy Markdown
Member

I'll mark this PR as waiting-on-author then while alternative avenues are being explored.

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: Waiting for the PR author to address review comments and removed S-waiting-on-review Status: Waiting for a review to complete labels Mar 30, 2026
@rustbot

rustbot commented Mar 30, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@RalfJung

Copy link
Copy Markdown
Member

I just ran into the same ICE in #5128, without realizing it, and wrote a fix in #5129. My fix filters out generics earlier, inside iter_exported_symbols, which I think is preferable. I will hence close this PR, but I'll cherry-pick your test so that this is not just tested by test-cargo-miri.

@RalfJung RalfJung closed this Jun 24, 2026
@rustbot rustbot removed the S-waiting-on-author Status: Waiting for the PR author to address review comments label Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ICE]: Instance::mono: DefId(0:3 ~ ice_min_repro[2fa7]::foo) has type parameters when building with Miri

5 participants